#include <stdio.h>

unsigned rightrot(unsigned x, unsigned n);

int main()
{
    printf("out = %u", rightrot(0b01011111000010101111, 3));
    return 0;
}

unsigned rightrot(unsigned x, unsigned n)
{
    return  (~(~0u << n) & x) << (32 - n) | (x >> n);
}